﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aga.Psad.Backend.Entities;

namespace Aga.Psad.Backend.Repositories
{
    public class ClienteDeClienteRepository : RepositoryBase<ClienteDeCliente>
    {
        public List<ClienteDeCliente> GetByUserName(string username)
        {
            var clients = DC.ClienteDeClientes
                            .Where(c => c.Usuario.Contains(username))
                            .ToList();

            return clients.Where(c => c.Usuario.Split('|').Any(u => u.Equals(username))).ToList();
        }

        public ClienteDeCliente GetByExId(int exId)
        {
            return DC.ClienteDeClientes
                     .Where(c => c.ExId.Equals(exId))
                     .FirstOrDefault();
        }

        public List<ClienteDeCliente> GetByCuit(string cuit)
        {
            return DC.ClienteDeClientes
                     .Where(c => c.Cuit.Equals(cuit))
                     .ToList();
        }

    }
}
